import { createWebHashHistory, createRouter } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'index',
    component: () => import('@views/Index.vue'),
    children: [
      {
        path: '',
        name: 'home',
        meta: { title: '欢迎来到汉德低代码平台' },
        component: () => import('@views/Home.vue')
      },
      {
        path: '/template/:id',
        name: 'template',
        meta: { title: '模版详情' },
        component: () => import('@views/TemplateDetail.vue')
      },
      {
        path: '/works',
        name: 'works',
        component: () => import('@views/Works.vue'),
        meta: { title: '我的作品', requiredLogin: true }
      }
    ]
  },
  {
    path: '/editor/:id',
    name: 'editor',
    meta: { requiredLogin: true, title: '编辑我的设计', disableLoading: true },
    component: () => import('@views/Editor.vue')
  },
  {
    path: '/login',
    name: 'login',
    meta: { title: '登录到汉德低代码平台', redirectAlreadyLogin: true, disableLoading: true, disableError: false },
    component: () => import('@views/Login.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: routes as any
})

export default router
